<?php
/**
 * @Author: rocky
 * Date: 2019/9/27
 * Time: 10:25
 */

namespace app\shop\controller\api\v1;

use app\common\controller\BaseApiController;
use app\common\tools\Files;
use app\shop\model\ShopBanner;
use app\shop\model\ShopGoodsModule;
use think\db\Query;

class Index extends BaseApiController
{
    /*
     * 首页
     */
    public function getIndex()
    {
        $data['banner'] = ShopBanner::field('img_url,good_id')->where('status',1)->all();
        $data['cate'] = ShopGoodsModule::field('id,name')->where('status',1)->relation(['goods'=>function(Query $q){
            $q->field('shop_goods.id,title,mini_title,logo,price')->where('is_deleted',0)->removeOption('order')->orderRand()->limit(1)->append(['sale_count']);
        }])->select();
        $this->successCode($data);
    }
    //聊天
    public function getChat(){
        $data['customer_tel'] = sysconf('customer_tel');
        $data['wx_customer_qrcode'] = Files::getImgUrl(sysconf('wx_customer_qrcode'));
        $this->successCode($data);
    }
    //线下支付文本
    public function getOfflinePayment(){
        $data = sysconf('offline_payment_text|raw');
        $this->successCode($data);
    }
}